<html>
<head>
<link rel="stylesheet" type="text/css" href="./style.css" />
</head>
<img style="margin-left:42%; text-align:center" src="./img/logo_txt_only.jpg" />
<div style="text-align:center;background-color:#d0ddcf;border: 1px solid #9CAA9C;width:300px;margin-left:40%;margin-left:40%;">


<?php

include('functions.php');

dbConnect();


if(isset($_POST['sellerEmail']) && isLi()){
	$email = $_POST['sellerEmail'];
	$item = $_POST['item'];
	
	
	echo 'Reply-To E-mail: ' . liUser() . '@' . liDomain() . '<br /><br />';
	
	echo 'Item: ' . $item . '<br />';
	
	echo '<form action="contactSeller.php" method="post">';
	
	echo '<textarea name="contents" rows="6" cols="37">Email Contents Here</textarea>';
	
	echo '<input type="hidden" name="sellerEmail2" value="' . $email . '">';
	echo '<input type="hidden" name="item" value="' . $item . '">';
	
	echo '<input type="submit" value="Contact User!" />';
} else if(isset($_POST['sellerEmail2'])){
	$email = $_POST['sellerEmail2'];
	$item = $_POST['item'];
	
	$contents = $_POST['contents'];
	
	$liFullname = liFullname();
	
	logAction($liFullname, 'contacted user ' . $email . ' with the message "' . $_POST['contents'] . '"');
	
	$contents = 'CollegeHustler.com! - You have been contacted by ' . liFullname() . ' about your item "' . $item . '" with this message "' . $contents . '""';
	
	echo 'You have contacted the user about ' . $item . ', he may reply to ' . liFullname() . ' at his convenience';
	
	$headers = 'From: doNotReply@collegeHustler.com' . "\r\n" . 'Reply-To: ' . liFullname();
	
	$subject = 'You have been contacted on CollegeHustler.com about ' . $item;
	
	mail($email, $subject, $contents, $headers);
	
} else {
	$ip = $_SERVER['REMOTE_ADDR'];
	echo 'You do not have persmission to be on this page, your ip ' . $ip . ' has been logged';
	logAction($ip, 'unauthorized access to modifyitem.php page');
}

?>

</div>

<a style="margin-left:48%;text-align:center;color:black" href="<?= getUrl(); ?>">Return Home</a>

</html>